

/***
 * @Date            : 2024-06-02 23:40:04
 * @Author          : AnimateX(Baron)
 * @LastEditors     : AnimateX(Baron)
 * @LastEditTime    : 2024-06-02 23:40:12
 * @FilePath        : /src/p10.cpp
 * @CopyRight       : Copyright (c) 2024 RockChip Technology Co. Ltd. All rights reserved.
 * @Description     :
 */

#include "p10.h"
#include <iostream>


void exampleFunction(int a) {
    std::cout << "Value : " << a << '\n';
}


void testHomeWorkP10_07() {
    // Using typedef funcPtr
    FuncPtr funcA = exampleFunction;
    funcA(16);

    // Using using
    FuncPtrUsing funcB = exampleFunction;
    funcB(18);

    // using typdef define: container
    IntVector vec1 = { 1, 2, 3, 4 };
    for (int i : vec1) {
        std::cout << i << " ";
    }
    std::cout << '\n';

    VectorUsing<int> vec2 = { 5, 6, 7, 8 };
    for (int i : vec2) {
        std::cout << i << " ";
    }
    std::cout << '\n';
}


void funcTestA(int a) {
    std::cout << "funcTestA: " << a << std::endl;
}


void funcTestB(int a) {
    std::cout << "funcTestB: " << a << std::endl;
}


void funcTestC(int a) {
    std::cout << "funcTestC: " << a << std::endl;
}


void testFuncPtrArray() {
    void (*funcArray[3])(int) = {
        funcTestA,
        funcTestB,
        funcTestC
    };

    for (int i = 0; i < 3; ++i) {
        funcArray[i](i + 1);
    }
}


void processData(int data, CallBackFunc callback) {
    data *= 2;
    callback(data);
}

void myCallback(int result) {
    std::cout << "Callback result: " << result << '\n';
}


void myCallbackTest() {
    std::cout << "Callback test, Input value: " << 5 << '\n';
    processData(5, myCallback);
}
